package com.hisense.ovcloud.asop;

import com.mybatisflex.core.query.QueryWrapper;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcTransactionManagerAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.reactive.config.EnableWebFlux;


@SpringBootApplication(scanBasePackages={
        "com.hisense.ovcloud.commons",
        "com.hisense.ovcloud.asop"
}, exclude = {R2dbcAutoConfiguration.class, R2dbcDataAutoConfiguration.class, R2dbcTransactionManagerAutoConfiguration.class})
@EnableWebFlux
@EnableAsync
@EnableEncryptableProperties
@ComponentScan(basePackages = {
        "com.hisense.ovcloud.commons",
        "com.hisense.ovcloud.asop"})
@Slf4j
public class Main implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Override
    public void run(String... args){
    }

    @Bean
    @Primary
    public Validator springValidator() {
        return new LocalValidatorFactoryBean();
    }

    @Bean
    @Primary
    public QueryWrapper queryWrapper(){
        return QueryWrapper.create();
    }

}
